<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/29 0029
 * Time: 16:03
 */

namespace app\home\controller;
use think\Db;

class Tripshoot extends Base
{
        public function index(){
            //广告
            $data_banner = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and type=7')->order('sort desc,id desc')->field('banner_img,out_link')->find();
            $this->assign('data_banner',$data_banner);
            //拍摄基地
            $is_china = intval(input('param.is_china'));
            $where='is_del=0 and is_show=1 and sign="pc"';
            if($is_china){
                $where .=' and is_china = '.$is_china;
                $this->assign('is_china',$is_china);
            }else{
                $where .=' and is_china =1';
                $this->assign('is_china',1);
            }
            $data_qqlp = Db::name('qqlp')->where($where)->order('sort desc,id desc')->field('id,main_img,title,intro,is_china,place')->limit(4)->select();
            $this->assign('data_qqlp',$data_qqlp);
            $next_data = Db::name('qqlp')->where($where)->order('sort desc,id desc')->page(2,4)->select();
            $type = 1;
            if(!$next_data){
                $type = 2;
            }
            $this->assign('type',$type);
            //场馆基地(顶部导航推荐)
            $data_cg = Db::name('psjd')->where('is_del=0 and is_show=1 and sign="pc" and is_recom=1')->order('sort desc,id desc')->select();
            $this->assign('data_cg',$data_cg);
            $this->assign('data_seo',getColumnseo(5));
            return $this->fetch();
        }

    public function nr(){
        $id = intval(input('param.id'));
        if($id){
            $data = Db::name('qqlp')->where('id',$id)->find();
            $this->assign('data',$data);
        }
        //场馆基地(顶部导航推荐)
        $data_cg = Db::name('psjd')->where('is_del=0 and is_show=1 and sign="pc" and is_recom=1')->order('sort desc,id desc')->select();
        $this->assign('data_cg',$data_cg);
        $this->assign('data_seo',getColumnseo(5));
        return $this->fetch();
    }

    public  function  getmore()
    {
        $where = 'is_del=0 and is_show=1 and sign="pc"';
        $page = intval(input('post.page'));
        $is_china = intval(input('param.is_china'));
        if ($is_china) {
            $where .= ' and is_china=' . $is_china;
        }
        $data = Db::name('qqlp')->where($where)->page($page,4)->select();
        $next_data = Db::name('qqlp')->where($where)->order('sort desc,id desc')->page($page+1,4)->select();
        $type = 1;
        if(!$next_data){
            $type = 2;
        }
        if ($data) {
            return json(['code' => 1, 'data' => $data,'type'=>$type]);
        } else {
            return json(['code' => 0, 'msg' => '没有更多了']);
        }
    }
}